package com.lysj.admin.master.bussiness.admin.controller;

import com.lysj.admin.master.bussiness.admin.domain.Agent;
import com.lysj.admin.master.bussiness.admin.mapper.AgentMapper;
import com.lysj.admin.master.bussiness.admin.service.AgentService;
import com.lysj.admin.master.common.annotation.MyList;
import com.lysj.admin.master.common.spring.mpbase.MyController;
import com.lysj.admin.master.common.spring.mpbase.MyService;
import com.lysj.admin.master.common.spring.pagination.PageRequestDTO;
import com.lysj.admin.master.common.web.Resp;
import com.lysj.admin.master.common.web.RespUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @author Created by drj on 2020-01-06 11:04
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/admin/agent")
public class AgentController extends MyController<AgentMapper, Agent, PageRequestDTO> {

    @Resource
    private AgentService agentService;

    @Override
    public MyService<AgentMapper, Agent> getService() {
        return agentService;
    }

    @Override
    @MyList
    public Resp list(PageRequestDTO condition) {
        return super.list(condition);
    }

    @PostMapping("/save_agent")
    public Resp saveAgent(Agent model, String password) {
        agentService.saveAgent(model,password);
        return RespUtil.success("添加代理商成功,手机号是代理商登录账号");
    }
}
